package com.comdo.newup_loan;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.umeng.analytics.MobclickAgent;

import java.util.LinkedList;
import java.util.List;

import cn.jpush.android.api.JPushInterface;


public class MyApplication extends Application {

	public static Context context;
	public static MyApplication instance = null;
	private static MyApplication baseApplication;
	private List<Activity> activities = new LinkedList<Activity>();
	private List<Activity> inDustryActivities = new LinkedList<Activity>();
	public void onCreate() {
		super.onCreate();
		MobclickAgent.openActivityDurationTrack(false);
		baseApplication = this;
		context = this;
		JPushInterface.setDebugMode(false); 	// 设置开启日志,发布时请关闭日志
		JPushInterface.init(this);     		// 初始化 JPush
		String registrationId = JPushInterface.getRegistrationID(this);
		Log.e("registrationId",registrationId);
		MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);

	}
	public static Context getAppContext() {
		return baseApplication;
	}
	public void addActivity(Activity activity) {
		activities.add(activity);
	}
	public void addInDustryActivities(Activity activity) {
		inDustryActivities.add(activity);
}

	public void finishAll() {
		for (Activity activity : activities) {
			if (!activity.isFinishing()) {
				activity.finish();
			}
		}
	}
	public void finishAll1() {
		for (Activity activity : inDustryActivities) {
			if (!activity.isFinishing()) {
				activity.finish();
			}
		}
	}
	public synchronized static MyApplication getInstance() {
		if (null == instance) {
			instance = new MyApplication();
		}
		return instance;
	}


}
